#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>

#include "jackclient.h"

char *bin_name;

void help() {
  printf("\n%s ver. %s\n\n", PACKAGE_NAME, PACKAGE_VERSION);
  printf("Usage: %s [volume]\n\nWhere volume is volume level between 0.0 and 0.2. Default is 0.0001\n", bin_name);
  printf("To exit use ctrl-c or kill or shutdown jackd.\n\n");
  exit(1);
}

int main(int argc, char* argv[]) {
  
  bin_name = argv[0];

  float volume;

  if(argc==1) {
    volume = 0.0001f;
  }
  else if (argc==2) {
    if(strlen(argv[1])<10) {
      if(sscanf(argv[1], "%f", &volume)!=1) {
	help();
      }
      if(volume<0.0f || volume>0.2f) {
	help();
      }
    }
    else {
      help();
    }
  }
  else {
    help();
  }

  jackclient_init(volume);

  while(1) 
    sleep(60);
  
  jackclient_close();
  exit(0);
}

